<!--
  @dauthor : cpucode
  @date : 2021/2/19
  @time : 22:18
  @github : https://github.com/CPU-Code
  @csdn : https://blog.csdn.net/qq_44226094
-->

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>绑定事件</title>
    <script src="../../../../../../node_modules/vue/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        <!--直接写js片段-->
        <button @click="num++">增加</button>

        <!--使用函数名，该函数必须要在vue实例中定义-->
        <button @click="decrement">减少</button>

        <h2>
            num = {{num}}
        </h2>
    </div>

    <script>
        let app = new Vue({
            el:"#app",
            data:{
                num: 1
            },
            methods:{
                decrement(){
                    this.num--;
                }
            }
        });
    </script>
</body>
</html>